How to load the 'current' version of a module

I want to loop through all baselines of a module to gather some stats, so I'm using:
for baseline in module do {
then
load (baseline, false) //loads it in the background (slient)

This will get me through each baseline, but I can't get to the current version - I don't see any command to do so.
The alternative is to process the current before the FOR statement above, but actually there are stats from baseline history I want to establish first, so that sequence doesn't work well for me.

Can anyone help on how to do that?
kierant - Thu May 27 07:32:26 EDT 2010

Re: How to load the 'current' version of a module
Mathias Mamsch - Thu May 27 08:18:36 EDT 2010

I usually use this pattern:
 

Module mod = current
 
Skip sk = create() 
Baseline B = null
 
// put the current Module in there with a NULL baseline
put (sk, 99999, B) 
 
int i = 0
// put the baselines in the skip before the current Module
for B in current Module do { put (sk, i++, B) }
 
// iterate through the baselines + the current Module
for B in sk do {
     Module m 
     if (null B) m = mod else m = load(mod , B, false) 
     if (null m) {
         print "Could not load baseline " (versionString moduleVersion (fullName current,B)) "\n"
         continue
     }
 
     // do something with the module m
     print "Processing " (name m) " " (versionString moduleVersion m) "\n"
 
     // maybe close the baseline when you are finished?
     if (!null B) close m
}

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: How to load the 'current' version of a module
kierant - Fri May 28 05:16:48 EDT 2010

Mathias Mamsch - Thu May 27 08:18:36 EDT 2010

I usually use this pattern:
 

Module mod = current
 
Skip sk = create() 
Baseline B = null
 
// put the current Module in there with a NULL baseline
put (sk, 99999, B) 
 
int i = 0
// put the baselines in the skip before the current Module
for B in current Module do { put (sk, i++, B) }
 
// iterate through the baselines + the current Module
for B in sk do {
     Module m 
     if (null B) m = mod else m = load(mod , B, false) 
     if (null m) {
         print "Could not load baseline " (versionString moduleVersion (fullName current,B)) "\n"
         continue
     }
 
     // do something with the module m
     print "Processing " (name m) " " (versionString moduleVersion m) "\n"
 
     // maybe close the baseline when you are finished?
     if (!null B) close m
}

 


Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Thanks Mathias, that seems to work well. I guess the key is that you've used a separate handle (m) rather than the initial one (mod current) so that you can load it (current) or a specific baseline of it.

But one other problem I'm now finding: I need to load a specific view (because of its filter, for counting). So I've in the loop included:
load (view viewname)
(this is after load of baseline has already occured).

However this isn't doing the trick. I think it may be because it is loading the view on that initial module (mod) rather than the one I'm using in the loop (m), but I'm not sure.

Any ideas?

Re: How to load the 'current' version of a module
Mathias Mamsch - Fri May 28 06:02:57 EDT 2010

kierant - Fri May 28 05:16:48 EDT 2010
Thanks Mathias, that seems to work well. I guess the key is that you've used a separate handle (m) rather than the initial one (mod current) so that you can load it (current) or a specific baseline of it.

But one other problem I'm now finding: I need to load a specific view (because of its filter, for counting). So I've in the loop included:
load (view viewname)
(this is after load of baseline has already occured).

However this isn't doing the trick. I think it may be because it is loading the view on that initial module (mod) rather than the one I'm using in the loop (m), but I'm not sure.

Any ideas?

load view "Name" will load the view in the current Module. To load it within the module m do:
load (m, view "Name"). Regards, Mathias


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

Re: How to load the 'current' version of a module
llandale - Fri May 28 17:12:47 EDT 2010

kierant - Fri May 28 05:16:48 EDT 2010
Thanks Mathias, that seems to work well. I guess the key is that you've used a separate handle (m) rather than the initial one (mod current) so that you can load it (current) or a specific baseline of it.

But one other problem I'm now finding: I need to load a specific view (because of its filter, for counting). So I've in the loop included:
load (view viewname)
(this is after load of baseline has already occured).

However this isn't doing the trick. I think it may be because it is loading the view on that initial module (mod) rather than the one I'm using in the loop (m), but I'm not sure.

Any ideas?

>
:title=kierant wrote:}
> I guess the key is that you've used a separate handle (m) rather than the initial one (mod current) so that you can load it (current) or a specific baseline of it.

It should be routine for scripts that care what module invoked them to have some sort of "Module mCurr = current()" at the top of the code, and not modified anywhere. Rarely use 'current Module' elsewhere in the code since the 'current' module can and does change when other modules are open, in a pattern that's hard to predict. Later, when you really care you can issue "current = mCurr" to set it back; perhaps to load a view.

  • Louie